package com.ibuonline.b2b.member.service;

import java.util.List;

import com.dimeng.common.base.BaseServiceImpl;
import com.dimeng.common.model.PageBean;
import com.dimeng.common.util.StringUtil;
import com.ibuonline.b2b.common.Constants;
import com.ibuonline.b2b.entity.Inform;

/**
 * 
 * @author lianglong
 * @date Jul 7, 2011
 * @time 2:39:17 PM
 * @version V 1.0
 */
public class InformServiceImpl extends BaseServiceImpl<Inform> implements InformService {

	@Override
	public List<Inform> getInforsListByType(Integer informer, String type, String status, PageBean pageBean) {
		String[] fieldNames;
		Object[] fieldValues;
		if(StringUtil.notEmpty(status) && !Constants.INFORM_STATUS.equals(status)) {
			fieldNames = new String[]{"informer", "type", "status"};
			fieldValues = new Object[]{informer, type, status};
		} else {
			fieldNames = new String[]{"informer", "type"};
			fieldValues = new Object[]{informer, type};
		}
		return (List<Inform>)this.getByParams(fieldNames, fieldValues,
				pageBean.getStart(), pageBean.getPageSize());
	}

	@Override
	public int getRecordCount(Integer informer, String type, String status) {
		String[] fieldNames;
		Object[] fieldValues;
		if(StringUtil.notEmpty(status) && !Constants.INFORM_STATUS.equals(status)) {
			fieldNames = new String[]{"informer", "type", "status"};
			fieldValues = new Object[]{informer, type, status};
		} else {
			fieldNames = new String[]{"informer", "type"};
			fieldValues = new Object[]{informer, type};
		}
		return this.getRecordCountByParams(fieldNames, fieldValues);
	}

	@Override
	public List<Inform> getInforsListByType(String type, String status, PageBean pageBean) {
		String[] fieldNames;
		Object[] fieldValues;
		if(StringUtil.notEmpty(status) && !Constants.INFORM_STATUS.equals(status)) {
			fieldNames = new String[]{"type", "status"};
			fieldValues = new Object[]{type, status};
		} else {
			fieldNames = new String[]{"type"};
			fieldValues = new Object[]{type};
		}
		return (List<Inform>)this.getByParams(fieldNames, fieldValues,
				pageBean.getStart(), pageBean.getPageSize());
	}

	@Override
	public int getRecordCount(String type, String status) {
		String[] fieldNames;
		Object[] fieldValues;
		if(StringUtil.notEmpty(status) && !Constants.INFORM_STATUS.equals(status)) {
			fieldNames = new String[]{"type", "status"};
			fieldValues = new Object[]{type, status};
		} else {
			fieldNames = new String[]{"type"};
			fieldValues = new Object[]{type};
		}
		return this.getRecordCountByParams(fieldNames, fieldValues);
	} 

	
}
